package com.sad.jetpack.v1.datamodel.api.extension.client.socket.ipc;

import java.lang.reflect.Method;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public enum IPCChatDataType {


    TEXT(0,0),
    IMAGE_URL(1,0),
    VIDEO_URL(2,0),
    AUDIO_URL(3,0),
    LINK(4,0),
    HTML(5,0),
    CMD(6,0),
    FILE(7,1);

    private int typeCode=0;
    private int contentType=0;

    public int getContentType() {
        return contentType;
    }

    public int getTypeCode() {
        return typeCode;
    }


    IPCChatDataType(int typeCode, int contentType) {
        this.typeCode = typeCode;
        this.contentType = contentType;
    }
    private final static Map<String, IPCChatDataType>TYPE_MAP=new ConcurrentHashMap<>();
    public static IPCChatDataType getChatType(int code){
        return TYPE_MAP.get(code+"");
    }

    static {
        try {
            Class<IPCChatDataType> emCLass= IPCChatDataType.class;
            IPCChatDataType[] enumConstants=emCLass.getEnumConstants();
            Method getEnumCode = emCLass.getMethod("getTypeCode");
            for(IPCChatDataType item : enumConstants){
                int invokeID = (int) getEnumCode.invoke(item);
                TYPE_MAP.put(invokeID+"",item);
            }
        }catch (Exception e){
            e.printStackTrace();
        }

    }

    /*    public final static int TYPE_TEXT=0;//文本消息
    public final static int TYPE_IMAGE=1;//图片消息
    public final static int TYPE_VIDEO=2;//视频消息
    public final static int TYPE_AUDIO=3;//音频消息
    public final static int TYPE_LINK=4;//链接消息
    public final static int TYPE_HTML=5;//HTML消息
    public final static int TYPE_PROGRAM=6;//程序消息
    public final static int TYPE_FILE=7;//文件消息
    public final static int TYPE_CMD=8;//透传命令*/

}
